import {COUNT_ASSETS, LIST_ASSETS, CREATE_ASSET, DELETE_ASSET} from '@/services/api'
import {request, METHOD} from '@/utils/request'



export async function countAssets() {
    return request(COUNT_ASSETS, METHOD.GET)
}

export async function listAssets(pageNum,pageSize) {
    let data = new FormData();
    data.append('pageNum',pageNum);
    data.append('pageSize',pageSize);
    return request(LIST_ASSETS, METHOD.POST,data)
}

export async function createAsset(assetsName,
                                  assetsIp,
                                  assetsProtocol,
                                  assetsPort,
                                  assetsUsername,
                                  assetsPassword,
                                  privateKey,
                                  passphrase) {
    let data = new FormData();
    data.append('assetsName',assetsName);
    data.append('assetsIp',assetsIp);
    data.append('assetsProtocol',assetsProtocol);
    data.append('assetsPort',assetsPort);
    data.append('assetsUsername',assetsUsername);
    data.append('assetsPassword',assetsPassword);
    data.append('privateKey',privateKey);
    data.append('passphrase',passphrase);
    return request(CREATE_ASSET, METHOD.POST,data)
}

export async function deleteAsset(assetId) {
    let data = new FormData();
    data.append('assetId',assetId);
    return request(DELETE_ASSET, METHOD.POST,data)
}

export default {
    countAssets,
    listAssets,
    createAsset,
    deleteAsset
}
